package epimarket.manager;

import java.io.Serializable;
import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import epimarket.beans.Categorie;
import epimarket.beans.Sous_categorie;
import epimarket.helper.DBConnect;
import epimarket.helper.DBQuery;
import epimarket.helper.DBRequest;

@ManagedBean
@RequestScoped
public class Layout implements Serializable {
	private static final long serialVersionUID = 1L;
	
	public ArrayList<Categorie> getCat() {
		Categorie model = new Categorie();
		DBConnect db = new DBConnect();
		DBRequest<Categorie> dbr = new DBRequest<Categorie>(db, model);
		
		return dbr.all();
	}
	
	public ArrayList<Sous_categorie> getSouscategory(int id) {
		Sous_categorie model = new Sous_categorie();
		DBConnect db = new DBConnect();
		DBQuery<Sous_categorie> dbq = new DBQuery<Sous_categorie>();
		DBRequest<Sous_categorie> dbr = new DBRequest<Sous_categorie>(db, model);
		
		return dbr.select(dbq.where_eq("id_categorie", Integer.toString(id)).all(model));
	}
}
